Skip to content

Develop#118

Merged
LuernOutOfOrder merged 88 commits intomainfrom
develop
Feb 19, 2026
Merged

Develop#118
LuernOutOfOrder merged 88 commits intomainfrom
develop

Conversation

@LuernOutOfOrder
Copy link
Owner

This pull request introduces significant improvements and documentation to the kernel, focusing on enhanced task management, scheduler functionality, and core kernel data structures. It adds comprehensive documentation for kernel primitives, data structures, scheduler, and timing helpers, introduces new assembly routines for task sleeping and context management, and updates task and context structures to support more robust scheduling and blocking mechanisms. Additionally, linker and configuration changes expand available memory and feature flags.

Key changes include:


Documentation Additions and Improvements

  • Added new documentation files detailing kernel data structures, primitives, scheduler, and timing helpers, including invariants and usage guidelines (Documentation/kernel/data_structure.md, Documentation/kernel/primitives.md, Documentation/kernel/scheduler.md, Documentation/kernel/timing_helpers.md). [1] [2] [3] [4]
  • Expanded task documentation with details on the idle task and updated task/block control structures (Documentation/kernel/task.md). [1] [2] [3] [4]

Task and Scheduler Enhancements

  • Introduced TaskBlockControl enum and integrated it into the Task struct to better represent blocked task reasons and states (Documentation/kernel/task.md).
  • Added support for an idle task to ensure the scheduler always has at least one runnable task (Documentation/kernel/task.md, Cargo.toml). [1] [2]
  • Improved TaskContext struct to include new fields (ra, mstatus) for more accurate context switching and status tracking (Documentation/kernel/task.md, src/arch/riscv32/task/task_context.rs). [1] [2]
  • Updated context initialization to set mstatus appropriately for interrupt enabling (src/arch/riscv32/task/task_context.rs).

Assembly and Context Switch Improvements

  • Added new assembly routines for sleeping (sleep.S), improved context save/restore (save_context.S, restore_context.S), and updated trap entry/exit logic for preemptive scheduling and correct status management (src/arch/riscv32/asm/sleep.S, src/arch/riscv32/asm/save_context.S, src/arch/riscv32/asm/restore_context.S, src/arch/riscv32/asm/trap_entry.S). [1] [2] [3] [4] [5]
  • Modified yield and scheduler invocation to streamline rescheduling (src/arch/riscv32/asm/yield.S).
  • Registered new assembly routines in the architecture module (src/arch/riscv32/asm/mod.rs, src/arch/riscv32/mod.rs). [1] [2]

Feature Flags and Build Configuration

  • Added new feature flags for kernel logs, early print, test mode, and idle task support in Cargo.toml.
  • Increased RAM and ROM size in linker script to accommodate larger kernel and features (linkers/linker_test_mode.ld).
  • Updated crate version to 0.4.5 (Cargo.toml).

Utilities and Helpers

  • Added a helper function to retrieve the current CPU core using the mhartid CSR (src/arch/riscv32/helpers.rs).

These changes collectively improve the kernel's robustness, documentation, and scheduling capabilities, making it easier to maintain, extend, and understand.

LuernOutOfOrder and others added 30 commits February 5, 2026 11:50
Add a sleep primitive composed by an asm entry point and a rust
function, save the current task context and compute awake tick
Sleep is more a task public API fn than a primitive type
Add a small description, and very trivial documentation on all current
primitives types. If I haven't forgot any.
The ROM is not really used for now in test mode so it's ok I guess
Testing the invariants from sleep primitive, from the blocked queue and
the timer interrupt
Add run queue check for invariants
…e and timing_helpers to documentation

Split the primitives documentation to have more separate logic
documentation, data structure and timing helpers are not primitives so
there's should not be in the primitives documentation.
…eep test behavior

Add the info header to primitives task file to keep track of what is
tested at this point, update the task sleep test behavior to skipped to
not always running it
Add sleep and delay for task handling
…o test

Change the BUFFER static to RUN_QUEUE static using a config static for
max size, add a basic idle task, static, no change possible for the dev
calling it, and update the main function to create task and test. Need
sleep primitive to continue on this branch
The CpusState structure will be used to store all useful flags per CPU
core. Like scheduler flags, state flags, and more if needed.
LuernOutOfOrder and others added 22 commits February 17, 2026 15:31
…, fix task context to use correct mstatus value

Task context mstatus has been update to use 6152 instead of 8 to enable
M-mode on task,for now at least
Things are smelly, like if two task with different priority print, it
can cause race condition and corrupt uart driver leading to a complete
kernel crash(mcause = 7), but if the print or logging system is
protected with a mutex, or while printing, we deactivate interrupt,
there's no problem.
No runtime starting for now, execute the task manually
…trap-frame-reset

Improve dispatch to a real scheduler using preemption
@LuernOutOfOrder LuernOutOfOrder added this to the v0.4.5 milestone Feb 19, 2026
@LuernOutOfOrder LuernOutOfOrder self-assigned this Feb 19, 2026
@LuernOutOfOrder LuernOutOfOrder added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 19, 2026
@LuernOutOfOrder LuernOutOfOrder merged commit 58bbed9 into main Feb 19, 2026
6 checks passed
@LuernOutOfOrder LuernOutOfOrder deleted the develop branch February 19, 2026 10:40
@LuernOutOfOrder LuernOutOfOrder restored the develop branch February 19, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant